package com.im.users.utils;


import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.DecodedJWT;

public class JWTUtils {

    private static String sign = "im-app";

    public static String createToken(String json) {
        return JWT.create().withClaim("userInfo", json).sign(Algorithm.HMAC256(sign));
    }

    public static Boolean checkToken(String token) {
        try {
            DecodedJWT verify = JWT.require(Algorithm.HMAC256(sign)).build().verify(token);
            return true;
        } catch (Exception e) {
        }
        return false;
    }
}
